<template>
  <div class="hyDialog">
    <el-dialog
      center
      title="创建新租户"
      v-model="dialogVisible"
      :width="dialogWidth"
      size="mini"
      empty-text="当前没有数据"
      destroy-on-close
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="租户功能" name="first">
          <el-form
            ref="diaForm"
            :model="diaForm"
            label-width="120px"
            label-position="top"
            :rules="roleRoles"
          >
            <el-form-item label="租户标识" prop="name">
              <el-input v-model="diaForm.name"></el-input>
            </el-form-item>
            <el-form-item label="名称" prop="ShowName">
              <el-input v-model="diaForm.ShowName"></el-input>
            </el-form-item>
            <el-form-item label="数据库连接">
              <el-input v-model="diaForm.describe"></el-input>
            </el-form-item>
            <el-form-item label="管理员邮箱地址" prop="email">
              <el-input v-model="diaForm.email"></el-input>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <!-- <el-tab-pane label="角色权限" name="second">
          <el-checkbox v-model="checked1" label="用户"></el-checkbox>
          <el-checkbox v-model="checked2" label="角色"></el-checkbox>
          <el-checkbox v-model="checked3" label="租户"></el-checkbox>
          <el-checkbox v-model="checked4" label="激活"></el-checkbox>
        </el-tab-pane> -->
      </el-tabs>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="changeVisibility(false)">取消</el-button>
          <el-button @click="addShop" type="primary">添加</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, ref } from 'vue'

export default defineComponent({
  props: {
    tableItems: {
      type: Array,
      default: () => [],
    },
    dialogWidth: {
      type: String,
      default: '30%',
    },
  },
  setup() {
    // 显示
    let dialogVisible = ref(false)
    // 隐藏dialog
    function changeVisibility(e: boolean) {
      dialogVisible.value = e
    }
    const activeName = 'first'
    const diaForm = reactive({
      name: '',
      ShowName: '',
      describe: '',
      email: '',
    })
    // const checked1 = ref(true)
    // const checked2 = ref(false)
    // const checked3 = ref(false)
    // const checked4 = ref(false)
    const roleRoles = {
      name: [
        {
          required: true,
          message: '请输入租户标识',
          trigger: 'blur',
        },
      ],
      ShowName: [
        {
          required: true,
          message: '请输入名称',
          trigger: 'blur',
        },
      ],
      email: [
        {
          required: true,
          message: '请输入邮箱地址',
          trigger: 'blur',
        },
        {
          type: 'email',
          message: '请输入正确的邮箱地址',
          trigger: ['blur', 'change'],
        },
      ],
    }
    return {
      dialogVisible,
      activeName,
      diaForm,
      roleRoles,
      changeVisibility,
    }
  },
})
</script>

<style scoped lang="less">
.hyDialog {
}
</style>
